class Solution(object):
    def uniquePathsWithObstacles(self, obstacleGrid):
        """
        :type obstacleGrid: List[List[int]]
        :rtype: int
        """
        m = len(obstacleGrid)
        n = len(obstacleGrid[0])
        f = [[0] *n for _ in range(m)]
        for i in range(m):
            for j in range(n):
                if obstacleGrid[i][j]==1:
                    f[i][j]=0
                else:
                    # 初始条件
                    if i==0 and j==0:
                        f[i][j]=1
                    else:
                        f[i][j] = 0
                        if i-1>=0:
                            # 如果i==1 就只有i-1 方向的来  i!=1的话 两个方向 但是 为了使用i==1 所以分开写
                            f[i][j] += f[i - 1][j]
                        if j-1>=0:
                            f[i][j] +=  f[i][j - 1]
        return f[-1][-1]


a = [[1,0]]
s =Solution()
print(s.uniquePathsWithObstacles(a))